package com.panshi.servers.impl;

import com.panshi.mapper.TypeMapper;
import com.panshi.pojo.TypeVO;
import com.panshi.servers.TypeServers;
import io.swagger.annotations.ApiModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author XiaoWangYa
 * @version 1.0
 * @date 2020/8/4 0004 下午 2:52
 */
@Slf4j
@Service
@ApiModel("口腔分类Servers层")
public class TypeServersImpl implements TypeServers {

    @Autowired
    private TypeMapper yb_typeMapper;

    @Override   // 增加口腔分类
    @CacheEvict(value = "type", allEntries = true) // 清空缓存
    public void addTypeInfo(TypeVO yb_Type_VO) {
        yb_typeMapper.addTypeInfo(yb_Type_VO);
    }

    @Override   // 删除口腔分类
    @CacheEvict(value = "type", allEntries = true) // 清空缓存
    public void deleteTypeInfo(String id) {
        yb_typeMapper.deleteTypeInfo(id);
    }

    @Override   // 查询分类
    @Cacheable(value = "type", key = "#root.methodName") // 将数据存入缓存
    public List<TypeVO> queryTypeInfoAll() {
        log.info(" 查询数据库 --> 查询分类 ");
        return yb_typeMapper.queryTypeInfoAll();
    }

    @Override   // 查询咨询分类
    @Cacheable(value = "type", key = "#root.methodName") // 将数据存入缓存
    public List<TypeVO> queryArticleInfoAll() {
        log.info(" 查询数据库 --> 查询咨询分类 ");
        return yb_typeMapper.queryArticleInfoAll();
    }

    @Override   // 查询回答分类
    @Cacheable(value = "type", key = "#root.methodName") // 将数据存入缓存
    public List<TypeVO> queryAnswerInfoAll() {
        log.info(" 查询数据库 --> 查询回答分类 ");
        return yb_typeMapper.queryAnswerInfoAll();
    }

    @Override   // 修改口腔分类
    @CacheEvict(value = "type", allEntries = true) // 清空缓存
    public void updateTypeInfo(TypeVO yb_Type_VO) {
        yb_typeMapper.updateTypeInfo(yb_Type_VO);
    }
}
